<?php

namespace App\Admin\Controllers;

use App\Admin\Actions\Modal\memberModal;
use App\Admin\Repositories\Prize;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class PrizeController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Prize(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('name');
            $grid->column('img')->image('',100,100);
            $grid->column('sum');
            $grid->column('winners_num');
            $grid->column('probability');
            $grid->column('type')->using([1=>'抽奖卷',2=>'皮肤碎片',3=>'改名卡',4=>'铭文',5=>'砖石',6=>'皮肤',7=>'优惠卷',8=>'小黑砖',9=>'镭射包']);
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
            $grid->disableDeleteButton();
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new Prize(), function (Show $show) {
            $show->field('id');
            $show->field('name');
            $show->field('img')->image();
            $show->field('sum');
            $show->field('winners_num');
            $show->field('probability');
            $show->field('type');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Prize(), function (Form $form) {
            $form->display('id');
            $form->text('name');
            $form->image('img')->autoUpload();
            $form->number('sum');
            $form->number('probability');
            $form->text('code','兑换码')->help('实物奖品不用填写');
            $form->radio('type')->options([1=>'抽奖卷',2=>'皮肤碎片',3=>'改名卡',4=>'铭文',5=>'砖石',6=>'皮肤',7=>'优惠卷',8=>'小黑砖',9=>'镭射包']);
            $form->radio('status')->options([1=>'道具',2=>'优惠卷',3=>'实物'])->label('状态');

//            $form->display('created_at');
//            $form->display('updated_at');
        });
    }
}
